{extend name="public/base"/}
 {block name="content"}
       <!-- Content Header (Page header) -->
<section class="content-header">
<h1>
           优惠券管理
<small>Optional description</small>
</h1>
<ol class="breadcrumb">
	<li><a href="{:U('Index/index')}"><i class="fa fa-dashboard"></i> 首页</a></li>
	<li class="active">优惠券管理</li>
</ol>
</section>
<!-- Main content -->
<section class="content" style="min-height:980px;">
<div class="col-md-9" style="padding:0; width:100%">
	<div class="box box-primary">
		<div class="box-header with-border">
			<h3 class="box-title" ><a href="{:U('Coupon/index')}" class="btn btn-primary">领取者名单</a></h3>			
			<h3 class="box-title" ><a href="{:U('Coupon/generate')}" class="btn btn-primary">生成优惠券</a></h3>
			<h3 class="box-title" ><a href="{:U('Coupon/grant')}" class="btn btn-primary">发放优惠券</a></h3>
		</div>


			<!-- 列表页 -->
<div  id="pagedata">
    <div class="box-body no-padding">
        <div class="table-responsive mailbox-messages">
            <table class="table table-hover table-striped" id="list">
                <tbody>
                <!-- 标题栏 -->
                <tr>
                	<td style="width:60px;"></td>               	
                    <td style="width:160px;"><a href="">用户id</a></td>                    
                    <td style="width:160px;"><a href="">用户昵称</a></td>
                    <td style="width:160px;"><a href="#">优惠码个数/个</a></td>
                    <td style="width:160px;"><a href="#">操作</a></td>                   
                </tr>
                <!-- 标题栏 END -->


                <!-- 循环列表 默认循环20条 高度为980px -->
                {volist name="info" id="data"}
                <?php
                 $nums = M('coupon')->where('his='.$data['id'])->count();
                ?>
                <tr>
                    <td><input name="select_id" type="checkbox" value=""></td>
                    <td style="width:160px;">{$data.id}</td>                  
                    <td style="width:160px;">{$data.uname}</td>
                    <td style="width:160px;">{$nums}</td>                   
                    <td style="width:160px;">
                    	<a href="{:U('Coupon/list_coupon',array('mid'=>$data['id']))}">查看其优惠券</a>
                    </td>                                                        
                </tr>
                {/volist}              
                <!-- 循环列表 END -->


                </tbody>
            </table>
        </div>
    </div>
    <div class="box-footer no-padding" >
        <div class="mailbox-controls" style="margin-top:20px;margin-bottom:10px;">
            <input type="checkbox" id="all">
            <input type="button" value="全选" class="btn" id="selectAll">
            <input type="button" value="全不选" class="btn" id="unSelect">
            <input type="button" value="反选" class="btn" id="reverse">
            <input type="button" value="删除" class="btn" onclick="fn();">
        </div>

    </div>

</div>




			<!-- 列表页 -->




	</div>


	<!-- /. box -->
</div>

<!-- 批量删除 -->
<script>
$(function () {

	$("#all").click(function(){
    	if(this.checked){
        	$("#list :checkbox").prop("checked", true);
    	}else{
			$("#list :checkbox").prop("checked", false);
    	}
 	});

    $("#selectAll").click(function () {
         $("#list :checkbox,#all").prop("checked", true);
    });

    $("#unSelect").click(function () {
         $("#list :checkbox,#all").prop("checked", false);
    });

    $("#reverse").click(function () {
         $("#list :checkbox").each(function () {
              $(this).prop("checked", !$(this).prop("checked"));
         });
		 allchk();
    });


	$("#list :checkbox").click(function(){
		allchk();
	});


});


	function getValue(){
			var id = document.getElementsByName('select_id');
			var value = new Array();
			   for(var i = 0; i < id.length; i++){
				 if(id[i].checked)
				 value.push(id[i].value);
				 }
				$.ajax({
				  type:"post",
				  url:"{:U('Content/del_id')}",
				  dataType: "json",
				  data:{
					del_id:value,
				  },
				  success:　
				  function(data){
				   alert(data);
				  },

				});
			   //ajax 进行删除 END
			};

	function fn(){
		  if(confirm("确定删除吗")){
			 getValue();
			location.reload();
			history.go(0);
		  }else{
			  history.go(0);
		  }
	}


	function allchk(){
		var chknum = $("#list :checkbox").size();
		var chk = 0;
		$("#list :checkbox").each(function () {
			if($(this).prop("checked")==true){
				chk++;
			}
		});
		if(chknum==chk){
			$("#all").prop("checked",true);
		}else{
			$("#all").prop("checked",false);
		}
	}


	<!-- 排序开始-->
	$(":text").change(function(){
			$.ajax({
			  type:"post",
			  url:"{:U('Content/listorder')}",
			  dataType: "json",
			  data:{
				  listorder:$(this).val(),
				  listorder_id:$(this).data("orderid"),
			  },
			  success:　
			  function(data){
			   alert('排序成功');
			  },

		   });

	});
	 <!-- 排序结束-->


</script>

</section>
<!-- Main content END-->

    {/block}
